package com.welsy.user.command
{
	import mx.rpc.IResponder;
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.welsy.user.business.*;
	import com.welsy.util.Comparator;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.events.FaultEvent;
	import mx.controls.Alert;
	import mx.collections.ICollectionView;
	import mx.collections.Sort;
	import mx.collections.SortField;
	import mx.utils.ArrayUtil;
	import com.welsy.user.model.UserModelLocator;
	import com.welsy.authoring.vo.*;
	import com.welsy.authoring.vo.course.*;
	import com.welsy.user.event.SaveQuestionTrackEvent;
		
	
	/**
	 * @version	$Revision: 1.1 $
	 */
	public class SaveQuestionTrackCommand implements ICommand, IResponder
	{
	  	public function SaveQuestionTrackCommand()
		{	 
		}
	
		public function execute( event : CairngormEvent ): void
		{
			var saveTrackEvent:SaveQuestionTrackEvent = SaveQuestionTrackEvent( event );
			
			var delegate : SaveQuestionTrackDelegate = new SaveQuestionTrackDelegate( this );
			delegate.saveTrack(saveTrackEvent.question.id,saveTrackEvent.question.trackStatus,saveTrackEvent.isLast);			    			
		}
	
		public function result( event : Object ) : void
		{				
			var resultlist:XMLList = XMLList(event.result)
			var result:String = XML(resultlist.child(0).child(0)).toString()
			
			if (result != "ok") 
				Alert.show("Errore nel salvataggio")
		}

		public function fault( event : Object ) : void
		{
			var faultEvent : FaultEvent = FaultEvent( event );
			Alert.show( "Si è verificato un errore!" );
		}
	}

}